include('shared.lua')

--ENT.RenderGroup = RENDERGROUP_OPAQUE

function ENT:Think()
	local mining = self:GetNWBool("mining") 
	local entindex = self:GetNWEntity("roid")
	local ent = nil
	if entindex then 
		ent =  ents.GetByIndex( entindex )
	end	
	
	if mining == true and ent:IsValid() then
		--local startpos = self:NearestPoint(ent:GetPos())
		local startpos = self:GetPos() + self:GetUp()*24
		local endpos = ent:NearestPoint(self:GetPos())
		local multi = (endpos - startpos):Length()
		local time = CurTime()
	
		local effectdata = EffectData()
			effectdata:SetOrigin(endpos)
			effectdata:SetStart(startpos)
			effectdata:SetMagnitude(multi)
			util.Effect( "ice_mining_beam", effectdata )  
	end
end

function ENT:Draw()
	self:DoNormalDraw()
end

function ENT:DoNormalDraw()
	local e = self.Entity;
	if (LocalPlayer():GetEyeTrace().Entity == e and EyePos():Distance(e:GetPos()) < 256) then
		if ( self.RenderGroup == RENDERGROUP_OPAQUE) then
			self.OldRenderGroup = self.RenderGroup
			self.RenderGroup = RENDERGROUP_TRANSLUCENT
		end
		--self:DrawEntityOutline(1.0)
		self.Entity:DrawModel()
		if(self:GetOverlayText() ~= "") then
			AddWorldTip(e:EntIndex(),self:GetOverlayText(),0.5,e:GetPos(),e)
		end
	else
		if(self.OldRenderGroup) then
			self.RenderGroup = self.OldRenderGroup
			self.OldRenderGroup = nil
		end
		e:DrawModel()
	end
end

function ENT:DrawEntityOutline( size )
end



